﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CascadeDropDown.Library.Helpers
{
   public static class CodeHelpers
    {
       public static void DoIf<T>(this T instance, bool ensure, params Action<T>[] actionList) where T:class
       {
           if (ensure)
           {
               foreach (var action in actionList)
               {
                   action.Invoke(instance as T);
               }
           }
       }
       public static void DoIf<T>(this T instance, Func<T,bool> ensure, params Action<T>[] actionList) where T : class
       {
           if (ensure(instance))
           {
               foreach (var action in actionList)
               {
                   action.Invoke(instance as T);
               }
           }
       }
    }
}
